package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Platenumber;
import com.ruoyi.system.domain.TAuthorization;
import com.ruoyi.system.domain.vo.plateWithMap;
import com.ruoyi.system.service.IPlatenumberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * @author Xiexingxie
 * @date 2022/12/2 下午 03:25
 */

@RestController
@RequestMapping("/system/entering")
public class PlatenumberController extends BaseController {
    
    @Autowired
    private IPlatenumberService iPlatenumberService;

    @PreAuthorize("@ss.hasPermi('system:entering:list')")
    @GetMapping("/list")
    public TableDataInfo plateWithMaps(plateWithMap plateWithMap){
        startPage();
        List<plateWithMap> allplateNumber = iPlatenumberService.getAllplateNumber(plateWithMap);
        return getDataTable(allplateNumber);
    }

    /**
     * 导出车位授权列表
     */
    @PreAuthorize("@ss.hasPermi('system:entering:export')")
    @Log(title = "车位授权", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, plateWithMap plate)
    {
        List<plateWithMap> list = iPlatenumberService.getAllplateNumber(plate);
        ExcelUtil<plateWithMap> util = new ExcelUtil<plateWithMap>(plateWithMap.class);
        util.exportExcel(response,list,"车位车牌录入数据");
    }
    
    @PostMapping("/addplatenumberinfo")
    public boolean addplatenumberinfo(@RequestBody Platenumber platenumber){
        boolean addplatenumberinfo = iPlatenumberService.addplatenumberinfo(platenumber);
        logger.debug("添加的信息为：{}",addplatenumberinfo);
        return addplatenumberinfo;
    }
    
}
